<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        #box{
            height: 200px;
            background: #caf;
        }
    </style>
</head>
<body>
    <div id="box"></div>

    <script>
        //获取元素
        let box = document.querySelector('#box');

        //绑定事件
        box.ontouchstart = function(){
            console.log('你触摸了我...');
            this.startTime = Date.now();
        }

        box.onclick = function(){
            console.log('你点击了我...');
            this.endTime = Date.now();
            this.innerHTML = (this.endTime - this.startTime);
        }
        
        //触摸滑动事件
        box.ontouchmove = function(){
            console.log('触摸滑动中....');
        }

        //触摸结束事件
        box.ontouchend = function(){
            console.log('触摸结束');
        }

        //触摸打断事件
        box.ontouchcancel = function(){
            console.log('触摸被打断啦!!!');
        }


        // setTimeout(() => {
        //     alert('主人, 那家伙又来电话啦!!!');
        // }, 3000)

    </script>
</body>
</html>